package com.flute.framework.search.highlight;

import java.util.ArrayList;
import java.util.List;

import com.flute.tools.util.StringUtil;

/**
 * 标红策略完全相同实现类
 * 
 * @author Dave
 * 
 */
public class SameMarkStrategy implements IMarkStrategy {

	/**
	 * @see com.flute.Flute.mark.IMarkStrategy#getMarked(java.lang.String,
	 *      java.lang.String)
	 */
	@Override
	public MarkPosition[] getMarked(String keyword, String searchString) {
		List<MarkPosition> set = new ArrayList<MarkPosition>();
		String newss = StringUtil.getStandardString(searchString);
		keyword = StringUtil.getStandardString(keyword);
		int[] idx = StringUtil.getAllInDependentIndex(newss, keyword);
		for (int id : idx) {
			MarkPosition mp = new MarkPosition();
			mp.setSource(searchString);
			mp.setStart(id);
			mp.setEnd(id + keyword.length());
			set.add(mp);
		}
		return set.toArray(new MarkPosition[] {});
	}
}
